using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;
using DTO;

namespace DAO
{
    public class ThamSoDAO
    {
        DataProvider Provider;
        public ThamSoDAO()
        {
            Provider = new DataProvider();
        }

        public DataTable LayBangThamSo()
        {
            Provider.Connect();
            string str = "select * from ThamSo";
            DataTable dt = new DataTable();
            OleDbDataAdapter da;
            da = new OleDbDataAdapter(str, Provider.cn);
            da.Fill(dt);
            Provider.Disconnect();
            return dt;
        }
        public void SuaThamSo(ThamSoDTO tsDto)
        {
            Provider.Connect();
            // B3: Tao chuoi strSQL thao tac CSDL
            string str;
            str = "Update ThamSo Set SoBNToiDaTrongNgay = ?, TienKhamQuiDinh = ? ";
            OleDbCommand cmd = new OleDbCommand(str, Provider.cn);

            cmd.Parameters.Add("@SoBNToiDaTrongNgay", OleDbType.Integer);
            cmd.Parameters.Add("@TienKhamQuiDinh", OleDbType.Integer);

            cmd.Parameters["@SoBNToiDaTrongNgay"].Value = tsDto.SoBenhNhanToiDaTrongNgay;
            cmd.Parameters["@TienKhamQuiDinh"].Value = tsDto.TienKhamQuiDinh;

            cmd.ExecuteNonQuery();
            Provider.Disconnect();
        }

    }
}
